using UnityEngine;
using UnityEngine.UI;
using QFramework;
using System;
using UnityEngine.SceneManagement;

namespace QFramework.Adventure
{
	public class GameOverPanelData : UIPanelData
	{
	}
	public partial class GameOverPanel : UIPanel,IController
	{
		protected override void OnInit(IUIData uiData = null)
		{
			mData = uiData as GameOverPanelData ?? new GameOverPanelData();
			// please add init code here
		}
		
		protected override void OnOpen(IUIData uiData = null)
		{
			AudioKit.PlaySound(GameConfig.Auido_Over);
			UIEventTrigger.Get(btn_newGame).onClick = NewGameFun;
			UIEventTrigger.Get(btn_exit).onClick = ExitFun;
            Time.timeScale = 0;
            InputController.Instance.InputSTop = true;
        }

	
		protected override void OnShow()
		{
		}
		
		protected override void OnHide()
		{
		}
		
		protected override void OnClose()
		{
            UIEventTrigger.Get(btn_newGame).onClick = null;
            UIEventTrigger.Get(btn_exit).onClick = null;
            Time.timeScale = 1;
            InputController.Instance.InputSTop = false;
        }
        //===============>
        private void NewGameFun(GameObject go)
        {
			AudioKit.PlaySound(GameConfig.Auido_Btn01);
			UIKit.ClosePanel<PlayerControllerPanel>();
         
            UIKit.OpenPanel<LoadingPanel>(new LoadingPanelData() { sceneName = QAssetBundle.Level01_unity.LEVEL01 });
            GameData.loadState = LoadState.NEWGAME;
			
            CloseSelf();
        }
        private void ExitFun(GameObject go)
        {
            AudioKit.PlaySound(GameConfig.Auido_Btn01);

            UIKit.ClosePanel<PlayerControllerPanel>();
            UIKit.OpenPanel<UnLoadingPanel>();
            UIKit.OpenPanel<MainMenuPanel>();         
            CloseSelf();
        }

		public IArchitecture GetArchitecture()
		{
			return AdventureApp.Interface;
		}
	}
}
